package leetcode.tree_problem;

/**
 * 101. 对称二叉树
 * https://leetcode-cn.com/problems/symmetric-tree/
 */
public class IsSymmetric {
    public boolean isSymmetric(TreeNode root) {
        if (root == null )
            return true;
        return isMirror(root.left , root.right);
    }
    public boolean isMirror(TreeNode left , TreeNode right){
        if (left == null && right == null)
            return true;
        if (left == null || right == null)
            return false;
        if (left.val != right.val){
            return false;
        }
        return isMirror(left.left , right.right) && isMirror(left.right , right.left);
    }
}
